/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *
 * @author: jin Chen 
 * @date: Nov 29, 2005$
 * @version: 1.0
 */
package edu.psu.geovista.app.hce.dendroview.node;

import javax.swing.*;
import java.util.HashMap;
import java.util.Map;

public class BNodeFactory {
    protected Map nodes=new HashMap(2);

    public BNode createNode(int orient) {
        BNode node=null;
        if(orient == SwingConstants.NORTH||orient ==SwingConstants.SOUTH ){
            Object o = this.nodes.get(VerticalBNode.class);
            if(o==null){
                 o=new VerticalBNode();
                 nodes.put(VerticalBNode.class,o);
            }
            node=(BNode) o;

        }
        else if (orient ==SwingConstants.EAST ||orient ==SwingConstants.WEST ) {
             Object o = this.nodes.get(VerticalBNode.class);
            if(o==null){
                 o=new HorizontalBNode();
                nodes.put(HorizontalBNode.class,o);
            }
            node=(BNode) o;

        }
        else{

            new IllegalArgumentException(this.getClass().getName() +" unknown orientation:"+orient);

        }
        return node;
    }

}
